<?php

class Db_Tables_Channels extends Zend_Db_Table
{
    protected $_name = 'channels';
	var $province;
	var $skip_province;
	
	function GetChannels()
	{
		$result = array();
		
		if($this->province)
		{
			$data = $this->fetchAll("channel_status=1 and channel_province='".$this->province."'");

			if($data)
			{
				foreach($data as $d)
				{
					$result[$d['channel_id']] = array(
						'channel_name' => $d['channel_name'],
						'channel_image' => $d['channel_image']
					);
				}
			}
		}elseif($this->skip_province)
		{
			$data = $this->fetchAll("channel_status=1");

			if($data)
			{
				foreach($data as $d)
				{
					$result[$d['channel_id']] = array(
						'channel_name' => $d['channel_name'],
						'channel_image' => $d['channel_image']
					);
				}
			}
		}
		
		return $result;
	}
	
	function GetProvinces()
	{
		$result = array();
		
		$rows = $this->fetchAll();
		
		if($rows)
		{
			foreach($rows as $row)
			{
				if(!in_array($row['channel_province'], $result))
				{
					$result[] = $row['channel_province'];
				}
			}
		}
		
		return $result;
	}
}